package com.example.mapdata.utils;

import java.util.Random;

/**
 * @ClassName CodeRandomUtils
 * @Description TODO
 * @Author 23207
 * @Date 2024/9/27 8:43
 * @Version 1.0
 */
public class CodeRandomUtils {
    /**
     * 生成四位随机验证码
     */
    public static String generateCode() {
        String characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        StringBuilder captcha = new StringBuilder(4);
        Random random = new Random();
        for (int i = 0; i < 4; i++) {
            captcha.append(characters.charAt(random.nextInt(characters.length())));
        }
        return captcha.toString();
    }
}
